package org.fnzn.actlistener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.fnzn.dao.LrdUserMapper;
import org.fnzn.entity.FrontInfoScspVo;
import org.fnzn.exception.MyException;
import org.fnzn.util.SpringUtil;

/**
 * 贷审会会审执行前监听
 * @author zhaolulu
 *
 */
public class ExecutionPendTrialBeforeListener implements ExecutionListener{

	private static final long serialVersionUID = 1L;

	@Override
	public void notify(DelegateExecution execution) throws Exception {
		FrontInfoScspVo scspVo = (FrontInfoScspVo) execution.getVariable("scsp");
		LrdUserMapper lrdUserMapper=SpringUtil.getBean(LrdUserMapper.class);
		Map<String,Object> param=new HashMap<>();
		param.put("corpCd", scspVo.getCorpCd());
		param.put("roleCd", "0006");//贷审会成员
		List<Map<String, Object>>  list=lrdUserMapper.queryList(param);
		List<String> userList=new ArrayList<>();
		if(list.isEmpty()){
			throw new MyException("贷审会成员信息不存在");
		}else{
			for(Map<String,Object> user:list){
				userList.add(user.get("userId").toString());
			}
			execution.setVariable("userList", userList);
			execution.setVariable("passCount", 0);//通过数量
			execution.setVariable("noAgreeCount", 0);//拒绝数量
		}
				
	}

}
